package com.bianguo.android.apushdemo.utils;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

import com.bianguo.android.apushdemo.view.wiget.CircleTransform;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.request.RequestOptions;

/**
 * Created by Administrator on 2017/5/8.
 */

public class GlideUtil {

    public static void loadImage(Activity mContext, ImageView imageView, String url, int radius) {
        RequestBuilder<Drawable> load = Glide.with(mContext).load(url);
        RequestOptions requestOptions = new RequestOptions();
        requestOptions.centerCrop();
        if (radius > 0) {
            requestOptions.transform(new CircleTransform(mContext));
        }
        load.thumbnail(0.1f);
        load.apply(requestOptions).into(imageView);
    }

    public static void loadImage(Context mContext, ImageView imageView, String url, int radius) {
        RequestBuilder<Drawable> load = Glide.with(mContext).load(url);
        RequestOptions requestOptions = new RequestOptions();
        requestOptions.centerCrop();
        if (radius > 0) {
            requestOptions.transform(new CircleTransform(mContext));
        }
        load.thumbnail(0.1f);
        load.apply(requestOptions).into(imageView);
    }

    public static void loadImage(Activity mContext, ImageView imageView, int resId, int radius) {
        RequestBuilder<Drawable> load = Glide.with(mContext).load(resId);
        RequestOptions requestOptions = new RequestOptions();
        requestOptions.centerCrop();
        if (radius > 0) {
            requestOptions.transform(new CircleTransform(mContext));
        }
        load.thumbnail(0.1f);
        load.apply(requestOptions).into(imageView);
    }

    public static void loadImage(Context mContext, ImageView imageView, int resId, int radius) {
        RequestBuilder<Drawable> load = Glide.with(mContext).load(resId);
        RequestOptions requestOptions = new RequestOptions();
        requestOptions.centerCrop();
        if (radius > 0) {
            requestOptions.transform(new CircleTransform(mContext));
        }
        load.thumbnail(0.1f);
        load.apply(requestOptions).into(imageView);
    }

    public static void pauseRequests(Activity mContext) {
        Glide.with(mContext).pauseRequests();
    }

    public static void pauseRequests(Context mContext) {
        Glide.with(mContext).pauseRequests();
    }

    public static void resumeRequests(Activity mContext) {
        Glide.with(mContext).resumeRequests();
    }

    public static void resumeRequests(Context mContext) {
        Glide.with(mContext).resumeRequests();
    }
}
